import {request} from '../utils/request'

export function getAllByReceiver(params) {
    return request({
        method: 'get',
        url: 'message/' + params.receiver,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

export function getAllMessage(params) {
    return request({
        method: 'get',
        url: 'message/getAll',
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

export function selectByTitle(params) {
    return request({
        method: 'get',
        url: 'message/selectByTitle/' + params.title,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

export function updateStatus(params) {
    return request({
        method: 'post',
        url: 'message/updateStatus/' + params.id,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

export function updateC(params) {
    return request({
        method: 'put',
        url: 'message/update',
        data: params,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

export function deleteById(params) {
    return request({
        method: 'delete',
        url: 'message/delete/' + params.id,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

export function getUnreadNum(params) {
    return request({
        method: 'get',
        url: 'message/getUnreadNum/' + params.id,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}

export function addMessage(params) {
    return request({
        method: 'post',
        url: 'message/add',
        data: params,
        headers: {
            'Authorization': window.localStorage.token,
        },
    })
}